home *** CD-ROM | disk | FTP | other *** search
/ Champak 33 / Volume 33 - JOGO DISK .iso / Games / space_escape.swf / scripts / DefineSprite_58_game / frame_1 / DoAction.as
Text File  |  2007-01-15  |  4KB  |  106 lines

  1. this.attachMovie("game_world","world",0);
  2. this.attachMovie("game_ship","ship",1);
  3. this.attachMovie("game_display","display",2);
  4. this.ship._x = 300;
  5. this.ship._y = 225;
  6. active = true;
  7. paused = false;
  8. inactiveCount = 0;
  9. thisFrameTime = getTimer();
  10. lastFrameTime = getTimer();
  11. this.onEnterFrame = function()
  12. {
  13.    var _loc1_ = _root;
  14.    var _loc2_ = this;
  15.    thisFrameTime = getTimer();
  16.    _loc1_.timeSecs = (thisFrameTime - lastFrameTime) / 1000;
  17.    if(!Key.isToggled(20))
  18.    {
  19.       paused = false;
  20.    }
  21.    else
  22.    {
  23.       paused = true;
  24.    }
  25.    if(active == true)
  26.    {
  27.       if(paused == false)
  28.       {
  29.          shipHitAX = _loc2_.ship._x;
  30.          shipHitAY = _loc2_.ship._y;
  31.          shipHitBX = _loc2_.ship._x + 10 * Math.sin((_loc2_.ship._rotation + 90) * 0.017453292519943295);
  32.          shipHitBY = _loc2_.ship._y - 10 * Math.cos((_loc2_.ship._rotation + 90) * 0.017453292519943295);
  33.          shipHitCX = _loc2_.ship._x + 10 * Math.sin((_loc2_.ship._rotation - 90) * 0.017453292519943295);
  34.          shipHitCY = _loc2_.ship._y - 10 * Math.cos((_loc2_.ship._rotation - 90) * 0.017453292519943295);
  35.          if(_loc2_.world.shape.hitTest(shipHitAX,shipHitAY,true) || _loc2_.world.objects.hitTest(shipHitAX,shipHitAY,true) || _loc2_.world.shape.hitTest(shipHitBX,shipHitBY,true) || _loc2_.world.objects.hitTest(shipHitBX,shipHitBY,true) || _loc2_.world.shape.hitTest(shipHitCX,shipHitCY,true) || _loc2_.world.objects.hitTest(shipHitCX,shipHitCY,true))
  36.          {
  37.             active = false;
  38.             _loc2_.ship.active = false;
  39.             _loc2_.ship.attachMovie("game_ship_graphic#explosion","graphic",0);
  40.             if(_loc1_.soundOn == true)
  41.             {
  42.                _loc1_.effectsSound = new Sound();
  43.                _loc1_.effectsSound.attachSound("sound_explosion");
  44.                _loc1_.effectsSound.start(0,0);
  45.             }
  46.          }
  47.          if(_loc1_.game.world.startFinish.endPlate.hitTest(_loc1_.game.ship._x,_loc1_.game.ship._y,true))
  48.          {
  49.             active = false;
  50.             _loc2_.ship.active = false;
  51.             _loc2_.ship.attachMovie("game_ship_graphic#finish_" + _loc1_.shipType,"graphic",0);
  52.             if(_loc1_.soundOn == true)
  53.             {
  54.                _loc1_.effectsSound = new Sound();
  55.                _loc1_.effectsSound.attachSound("sound_fanfare");
  56.                _loc1_.effectsSound.start(0,0);
  57.             }
  58.          }
  59.          if(_loc1_.timeBonus > 0)
  60.          {
  61.             _loc1_.timeBonus -= _loc1_.timeSecs;
  62.          }
  63.       }
  64.    }
  65.    else
  66.    {
  67.       paused = false;
  68.       if(inactiveCount >= 60)
  69.       {
  70.          if(_loc1_.pTimeTrial == true)
  71.          {
  72.             if(_loc1_.game.world.startFinish.endPlate.hitTest(_loc1_.game.ship._x,_loc1_.game.ship._y,true))
  73.             {
  74.                _loc1_.gotoAndStop("trialCompleted");
  75.                removeMovieClip(_loc2_);
  76.             }
  77.             else
  78.             {
  79.                _loc1_.gotoAndStop("trialFailed");
  80.                removeMovieClip(_loc2_);
  81.             }
  82.          }
  83.          else if(_loc1_.game.world.startFinish.endPlate.hitTest(_loc1_.game.ship._x,_loc1_.game.ship._y,true))
  84.          {
  85.             _loc1_.gotoAndStop("levelCompleted");
  86.             removeMovieClip(_loc2_);
  87.          }
  88.          else if(_loc1_.lives > 0)
  89.          {
  90.             _loc1_.gotoAndStop("levelFailed");
  91.             removeMovieClip(_loc2_);
  92.          }
  93.          else
  94.          {
  95.             _loc1_.gotoAndStop("gameOver");
  96.             removeMovieClip(_loc2_);
  97.          }
  98.       }
  99.       else
  100.       {
  101.          inactiveCount++;
  102.       }
  103.    }
  104.    lastFrameTime = thisFrameTime;
  105. };
  106.